package migrations

import "gitlib.com/migrate/schema"

var CreateUserTable2021_05_10_182112 = &createUserTable2021_05_10_182112 {}

func init()  {
	DataMap["2021_05_10_182112_create_user_table"] = CreateUserTable2021_05_10_182112
}

type createUserTable2021_05_10_182112 struct {
}

func (t *createUserTable2021_05_10_182112) Up() {
	// 创建用户表
	schema.NewSchema().CreateTable("user", func(builder *schema.Builder) {
		builder.BigIncrements("id")
		builder.String("open_id", 32).Unique().Default("").Comment("平台用户标识")
		builder.String("nickname", 64).Default("").Comment("用户在平台昵称")
		builder.String("avatar").Default("").Comment("用户在平台头像")
		builder.UnsignedInteger("last_login_time").Default(0).Comment("最新登录时间")
		builder.UnsignedInteger("login_times").Default(0).Comment("登陆次数")
		builder.UnsignedInteger("continue_login_days").Default(0).Comment("连续登陆天数")
		builder.UnsignedInteger("date").Default(0).Comment("注册日期")
		builder.String("qq", 20).Unique().Default("").Comment("用户QQ号")
		builder.UnsignedTinyInteger("status").Default(0).Comment("用户状态，0:正常;1:可疑；2:封禁")

		builder.Timestamps()
	})
}

func (t *createUserTable2021_05_10_182112) Down() {
	// 删除用户表
	schema.NewSchema().DropTableIfExists("user")
}
